<?php
loadTemp("admin/models/class/classheader.php");
?>
<script type="text/javascript">
$(document).ready(function(){
	loadAdminTopItem();
	activeAdminTopItem("s_c_manageclass");
	$("#studentlist_temple").hide();
});
</script>
<?php checkAdminPermission("admin.class.manager_class","admin.class.*");?>
<script type="text/javascript">
$(document).ready(function(){
	bindAjaxForm($("#form_manager_search"),s_managerclass_onSuccess,s_managerclass_onError,"admin_di");
});
function s_managerclass_onSuccess(data){
	s_managerclass_operatedone(data.code,data.message,data.data);
}
function s_managerclass_onError(data){
	console.log(data);
	s_managerclass_operatedone(-101,"服务器返回了未知的数据，请上报管理员",data.responseText);

}
function s_managerclass_operatedone(id,message,data){
	if(id==-101){
		showMessage("s_managerclass_message",-101,message+"<br><br><pre>"+data+"</pre>");
		return;
	}
	if(id!=0&&id!=3){
		showMessage("s_managerclass_message",id,message);
	}
	if(id==0){
		showMessage("s_managerclass_message",id,message);
	}
	if(data.op=="manage_data"){
		$("#form_manager_search").hide();
		$.each(data.data,function(k,v){
			addStudent(v);
		});
	}
	if(data.op=="removeStudent"){
		$("#s_stu_"+data.uid).remove();
	}
	
}
function s_removestudent(e){
	$uid = e.attr("uid");
	ajaxRequest("uid="+$uid,"admin.php?mod=class&ajax=true&op=remove_student",s_managerclass_onSuccess,s_managerclass_onError);
}

function addStudent(data){
	var $tmp = $("#studentlist_temple").clone();
	$tmp.show();
	$tmp.attr("id","s_stu_"+data.uid);
	$tmp.find(".s_name").html(data.card.name).attr("href",getHomeURL(data.card.uid));
	$tmp.find(".s_stuid").html(data.stuid);
	$tmp.find(".s_uid").attr("uid",data.card.uid);
	$tmp.find(".s_head").attr("src",data.card.head_image_path);
	$tmp.find(".s_subject").html(data.displayname);
	$("#s_m_c_student_list").append($tmp);
}

</script>
<div class="s_admin_in_container">
	<h2 class="ui dividing header">班级管理</h2>
	<div class="ui message">
		<div class="header">小提示</div>
		<ul class="list">
			<li>这里是班级管理模块</li>
			<li>你可以在这里查看和管理班级人员</li>
		</ul>
	</div>
	<div class="ui message hidden" id="s_managerclass_message"></div>
	<form class="ui form" url="admin.php?mod=class&ajax=true&op=search_manage_class" id="form_manager_search">
		<div class="ui action fluid input">
			<div class="ui left icon input">
				<input type="text" name="classid" placeholder="请输入你要管理的班级的班级id">
				<i class="users icon"></i>
			</div>
			<button class="ui button submit" type="submit">确定</button>
		</div>
	</form>
	<h4 class="ui dividing header">学生列表</h4>
	<div class="ui middle relaxed aligned divided list" id="s_m_c_student_list"></div>
</div>
<div class="item" id="studentlist_temple">
	<div class="right floated content">
		<a class="lm_item s_uid" onClick="s_removestudent($(this));">删除</a>
	</div>
	<img class="ui avatar image s_head" src="">
	<div class="content s_description">
		<a class="s_name"></a>
		<div class="lm_item s_stuid"></div>
	</div>
</div>